package demo;

import java.util.*;

/**
 * @Author liangzai
 * @Description:
 */
public class Main {
    public static void main(String[] args) {
        long ret1 = 0;int ret2 = 0;
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int a1 = scanner.nextInt();int a2 = scanner.nextInt();int b1 = scanner.nextInt();
        int b2 = scanner.nextInt(); int b3 = scanner.nextInt();
        int[][] nums = new int[1001][4];
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            nums[x][y]++;
            set.add(x);
        }
        HashMap<Integer , Integer> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            map.put(x,y);
        }
        for(Integer day : set){
            int A1 = 0;int A2 = 0;int B1 = 0;int B2 = 0;int B3 = 0;

                if(nums[day][1]!=0){
                    A1 += a1*nums[day][1];
                    B1 += b1*nums[day][1];
                }
                if(nums[day][2]!=0){
                    B2 += b2*nums[day][2];
                }
                if(nums[day][3]!=0){
                    A2 += a2*nums[day][3];
                    B3 += b3*nums[day][3];
                }

            if(map.containsKey(day)){
                int val = map.get(day);
                if(val==1){
                    B1 /= 2;
                }else if(val == 2){
                    B2 /= 2;
                }else {
                    B3 /= 2;
                }
            }
            ret1 = ret1 + A1 -A2;
            ret2 = ret2 - B1 - B2 - B3;
        }
        System.out.println(ret1+" "+ret2);
    }


}
